﻿@using GSLMS.WebAPP
@model GSLMS.Entity.TB_APP_REFREGINFO
@{
    Layout = null;
    var ddlCustList = ViewData["CustList"] as SelectList;
}
<div class="pageContent">
    <form method="post" id="formRefRegCreate" action="DianDang/Apply/RefRegInfo/Create?OpID=@ViewData["OperateID"]" class="pageForm required-validate"
    onsubmit="return validateCallback(this, dialogAjaxDone)">
    @Html.ValidationSummary(true)
    <div class="pageFormContent" layouth="56">
        @Html.Hidden("ID",Model.ID)
        @Html.Hidden("RefRegInfoSubmitButton")
        <p>
            <label>
                客户名称：</label>
            @Html.DropDownListFor(model => model.REGINFOID, ddlCustList, HelperCommon.SelectDefaultValue, new { @class = "required", @selectedvalue = Model.REGINFOID, @sumbitText = "CUSTNAME", @onchange = "GetRefCustomerInfo(this)" })
            @Html.ValidationMessageFor(model => model.CUSTNAME)
           
        </p>
        <p>
            <label>
                转介人：</label>
            @Html.TextBoxFor(model => model.REFBY, new { @class = "", @readonly = "true" })
            @Html.HiddenFor(model=>model.REFBYNAME)
            @Html.ValidationMessageFor(model => model.REFBY)
        </p>
        <p>
            <label>
                申请日期：</label>
            @Html.TextBoxFor(model => model.APPDATE, new { @class = "", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.APPDATE)
        </p>
        <p>
            <label>
                转出部门：</label>
            @Html.TextBoxFor(model => model.OUTDEPNAME, new { @readonly = "true" })
            @Html.ValidationMessageFor(model => model.OUTDEPNAME)
            @Html.HiddenFor(model => model.OUTDEPID)
        </p>
        <p>
            <label>
                转出时间：</label>
            @Html.TextBoxFor(model => model.OUTTIME, new { @class = "", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.OUTTIME)
        </p>
        <p>
            <label>
                转入部门：</label>
            @Html.TextBoxFor(model => model.INDEPNAME, new { @readonly = "true" })
            @Html.ValidationMessageFor(model => model.INDEPNAME)
            @Html.HiddenFor(model => model.INDEPID)
        </p>
        <p>
            <label>
                转入时间：</label>
            @Html.TextBoxFor(model => model.INTIME, new { @class = "", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.INTIME)
        </p>
        <p>
            <label>
                后续业务员：</label>
            @Html.TextBoxFor(model => model.SALESMAN, new { @class = "", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.SALESMAN)
            @Html.HiddenFor(model => model.SALESMANID)
        </p>
        <div class="divider">
        </div>
        <p style="width: 90%">
            <label>
                详细内容：</label>
            @Html.TextAreaFor(model => model.DETAIL, new { @cols = "70", @rows = "5" })
            @Html.ValidationMessageFor(model => model.DETAIL)
            @Html.HiddenFor(model => model.STATUS);
        </p>
    </div>
   <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit" onclick="toSave(0)">
                            保存</button></div>
                </div>
            </li>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit" onclick="toSave(1)">
                            提交</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
<script>

    function toSave(n) {
        $("#STATUS").val(n);
    }

    function GetRefCustomerInfo(obj) {
        $this = $(obj);
        var $form = $("#formRefRegCreate");
        var id = $this.val();
        if (id) {
            $.ajax({
                type: 'POST',
                url: "DianDang/Apply/RefRegInfo/GetRefCustomerInfo/" + id,
                data: { id: id },
                cache: false,
                dataType: "json",
                success: function (response) {
                    var json = eval(response);
                    if (json.REGDATE) {
                        var date = new Date(parseInt(json.REGDATE.substr(6)));
                        $("#APPDATE", $form).val(date.formatDate("yyyy-MM-dd"));
                    }
                   
                    $("#OUTDEPNAME").val(json.DEPNAME);
                    $("#OUTDEPID").val(json.DEPID);
                   
                }
            });
        }
    }
</script>
